(function () {
    var fileicon = {
        "音频": "audio48.png",
        "视频": "video48.png",
        "图片": "image48.png",
        "压缩": "zip48.png",
        "程序": "code48.png",
        ".doc": "word48.png",
        ".docx": "word48.png",
        ".ppt": "pptx48.png",
        ".pptx": "pptx48.png",
        ".xls": "xlsx48.png",
        ".xlsx":"xlsx48.png",
        "":"other48.png"
    
    };
    return {
        formatSize: function (size) {
            size = $.toInt(size);
            if (size >= 1024 * 1024 * 1024) {
                return ""+(size / (1024 * 1024 * 1024)).toFixed(2)+" GB";
            }else if (size >= 1024 * 1024 ) {
                return ""+(size / (1024 * 1024)).toFixed(2)+" MB";
            }else if (size >= 1024 ) {
                return ""+(size / 1024).toFixed(2)+" KB";
            } else {
                return "" + size + " B";
            }
        },
        getDocIcon: function (doctype, filetype,isfolder) {
            var root = "/tpl/theme/default/images/oa/doc/filetype/";
            if (isfolder) {
                return root + "folder.png";
            }
            if (doctype in fileicon) {
                return root + fileicon[doctype];
            }
            if (filetype in fileicon) {
                return root + fileicon[filetype];
            }
            return root + fileicon[""];
        }
    }
})();